<?php
/**
 * Created by PhpStorm.
 * UsersF: Mloong
 * Date: 2018/11/30
 * Time: 10:34
 */

namespace app\admin\model;


use Driver\Cache\Redis;

class Account extends BaseModel
{
    # 查找一条记录\
    public static function findOne($id)
    {
        return self::where('id','=',$id)
            ->find()
            ->hidden(['pwd'])
            ->toArray();
    }
    # 更新状态
    public static function upStatus($pose_data)
    {
        return self::where('id','=',$pose_data['id'])
            ->update([
                'status' => $pose_data['status']
            ]);
    }
    # 删除一条记录
    public static function delOne($id)
    {
        Redis::redisAccountSet('From','del',$id);
        return self::destroy($id);
    }

    # 更新是否允许重复
    public static function upRepeat($pose_data)
    {
        return self::where('id','=',$pose_data['id'])
            ->update([
                'repeat' => $pose_data['repeat']
            ]);
    }

    # 根基name获取id
    public static function get_id($name)
    {
        return self::where('name', '=', $name)
            ->find()
            ->toArray();
    }

    # 根基id获取name
    public static function get_name($id)
    {
        return self::where('id', '=', $id)
            ->find()
            ->toArray();
    }
}